#include "InstructionsState.h"
#include "stdafx.h"
/**************************************************************/
// GetInstance
//	- store the ONLY instance in global memory
//	- return the only instance by pointer
/*static*/ InstructionsState* InstructionsState::GetInstance(void)
{
	static InstructionsState s_Instance;

	return &s_Instance;
}


/**************************************************************/
// Enter
//	- reset the game & load resources
void InstructionsState::Enter(void)
{
	
	// Set background color
	SGD::GraphicsManager::GetInstance()->SetClearColor({ });	// BLACK

	m_bSecondScreen = false;
	m_bThirdScreen = false;

}

/**************************************************************/
// Exit
//	- deallocate / unload resources
/*virtual*/ void InstructionsState::Exit(void)
{
}

/**************************************************************/
// Input
//	- Handles User Input
bool InstructionsState::Input()
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();

	if (Game::GetInstance()->MenuBackInput())
		Game::GetInstance()->ChangeState(MainMenuState::GetInstance());

	if (theGame->MenuConfirmInput())
	{
		if (m_bThirdScreen)
		{
			m_bThirdScreen = false;
		}
		else if (m_bSecondScreen)
		{
			m_bSecondScreen = false;
			m_bThirdScreen = true;
		}
		else
		{
			m_bSecondScreen = true;
		}


	}


	return true;
}
/**************************************************************/
// Update
//	- update Objects / animations
 void InstructionsState::Update(float elapsedTime)
{
}
/**************************************************************/
// Render
//	- Render Objects / animations
 void InstructionsState::Render()
{
	 // Use the game's font
	 BitmapFont* pFont = Game::GetInstance()->GetFont();

	 // Align text based on window width
	 int width = (int)Game::GetInstance()->GetScreenWidth();

	 SGD::GraphicsManager * pGraphics = SGD::GraphicsManager::GetInstance();
	
	 pGraphics->DrawTexture(theGame->GetMenuBackground(), { 0, 0 });

	 if (m_bSecondScreen)
	 {
	 pGraphics->DrawTextureSection(theGame->GetControllerImage(), {0,100}, {0,0,675,390});//675x390
	 pFont->Draw("CONTROLLER INPUT", (int)((width - (4 * 32 * 4.0f)) / 2)-50, 50, 1.0f, {255,0,0});
	 pFont->Draw("Press A for Keyboard", 25, 500, .6f, {255,0,0});
	 pFont->Draw("Press B to Exit", 25, 535, .6f, { 255, 0, 0 });
	}
	 else if (m_bThirdScreen)
	 {
		 pGraphics->DrawTextureSection(theGame->GetControllerImage(), { 0, 0 }, { 0, 410, 710, 970 });//710x540
	//	 pFont->Draw("KEYBOARD INPUT", (int)((width - (4 * 32 * 4.0f)) / 2) - 50, 50, 1.0f, { 255, 0, 0 });
		 pFont->Draw("Press A for Instructions", 425, 500, .6f, { 255, 0, 0 });
		 pFont->Draw("Press B to Exit", 425, 535, .6f, { 255, 0, 0 });
	 }
	 else
	 {

		 pGraphics->DrawTextureSection(theGame->GetHTPImage(), { 0, 0 }, { 0, 0, 800, 600 });

		// pFont->Draw("INSTRUCTIONS", (int)((width - (4 * 32 * 4.0f)) / 2) - 50, 50, 1.0f, { 255, 0, 0 });
		 //print instructions image
		// pFont->Draw("Press A for Controller Input", 25, 500, .6, { 255, 0, 0 });
		 //pFont->Draw("Press B to Exit", 25, 535, .6, { 255, 0, 0 });
	 }

}

